package com.wicket.okrcomponent.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrcomponent.biz.service.dto.req.*;
import com.wicket.okrcomponent.biz.service.dto.res.*;
import com.wicket.okrcomponent.common.exception.BizException;
import com.wicket.okrcomponent.common.util.CommonFunctionHelper;
import com.wicket.okrcomponent.common.util.RedisUtil;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.wicket.okrcomponent.base.service.MOmsUnstructuredDataService;
import com.wicket.okrcomponent.common.exception.Assert;
import com.wicket.okrcomponent.biz.service.nb.NbDashboardTargetContent;
import com.wicket.okrcomponent.biz.service.ConfSchemeService;
import com.wicket.okrcomponent.base.service.MCustomFields3Service;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@Service
public class DashboardTargetContentServiceImpl
  implements com.wicket.okrcomponent.biz.service.DashboardTargetContentService {

  @Resource
  private RedisUtil redisUtil;
@Resource
  private MOmsUnstructuredDataService mOmsUnstructuredDataService;
@Resource
  private NbDashboardTargetContent nbDashboardTargetContent;
@Resource
  private ConfSchemeService confSchemeService;
@Resource
  private MCustomFields3Service mCustomFields3Service;
/**
   * D2准备大屏数据点评价模板配置(公共)[8950]
   * gen by moon at 6/17/2024, 10:23:37 AM
   */
  @Trace(operationName = "D2准备大屏数据点评价模板配置(公共)")
  @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Transactional(rollbackFor=Exception.class)
  @Override
  public PreparationDashboardDataPointEvaTempConfComRespDto preparationDashboardDataPointEvaTempConfCom(PreparationDashboardDataPointEvaTempConfComReqDto reqDto){
    
      
      ImplementTenReceivingFieldRespDto receptionServiceRes_2 =null;
//步骤0: M2执行第十接收字段（特殊方法） - implementTenReceivingField
     //ModelCode: receptionService
        ImplementTenReceivingFieldRespDto receptionServiceRes = null;
    ImplementTenReceivingFieldReqDto receptionServiceReq=new ImplementTenReceivingFieldReqDto();
  if(reqDto!=null){
      receptionServiceReq.setEvaluationTemplateId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:1673965_1
    }
  
    /*M2接收入参字段[8782]  用于特殊方法接收上游入参。 */
    Assert.isNull(receptionServiceReq.getEvaluationTemplateId(),"D2准备大屏数据点评价模板配置(公共)-M2接收入参字段-冗余评价模板ID不能为空",false);
      receptionServiceRes = nbDashboardTargetContent.implementTenReceivingField(receptionServiceReq);
      
      
      
    
//步骤1: D2-3查配置项匹配答案详情(公共)（跨服务） - queryConfItemMatchAnswerDetailCom
     QueryConfItemMatchAnswerDetailComRespDto queryConfItemMatchAnswerDetailComRespDto = null;
    QueryConfItemMatchAnswerDetailComReqDto queryConfItemMatchAnswerDetailComReqDto=new QueryConfItemMatchAnswerDetailComReqDto();
  queryConfItemMatchAnswerDetailComReqDto.setResultAspObjType("EVA_TEMP");//sourceId:1874250_1
  queryConfItemMatchAnswerDetailComReqDto.setConfItemCode("LAST_CYCLE_TYPE");//CUSTOM_CONVENTION//sourceId:1673822_1
queryConfItemMatchAnswerDetailComReqDto.setIsPlatData("FALSE");//sourceId:1673823_1
if(reqDto!=null){
      queryConfItemMatchAnswerDetailComReqDto.setResultAspObjId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:1673821_1
    }
  
    /*D2评价模板末级周期类型配置答案[2486]   */
    Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getResultAspObjId(),"D2准备大屏数据点评价模板配置(公共)-D2评价模板末级周期类型配置答案-开通对象ID不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getResultAspObjType(),"D2准备大屏数据点评价模板配置(公共)-D2评价模板末级周期类型配置答案-开通对象类型编码不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getConfItemCode(),"D2准备大屏数据点评价模板配置(公共)-D2评价模板末级周期类型配置答案-配置项标识不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getIsPlatData(),"D2准备大屏数据点评价模板配置(公共)-D2评价模板末级周期类型配置答案-是否标准答案不能为空",false);
      queryConfItemMatchAnswerDetailComRespDto = confSchemeService.queryConfItemMatchAnswerDetailCom(queryConfItemMatchAnswerDetailComReqDto)/*vcase invoke isSameApp*/;
      
      
      
    
//步骤2: D2-3查配置项匹配答案详情(公共)（跨服务） - queryConfItemMatchAnswerDetailCom
     QueryConfItemMatchAnswerDetailComRespDto queryConfItemMatchAnswerDetailComRespDto_2 = null;
    QueryConfItemMatchAnswerDetailComReqDto queryConfItemMatchAnswerDetailComReqDto_1=new QueryConfItemMatchAnswerDetailComReqDto();
  queryConfItemMatchAnswerDetailComReqDto_1.setResultAspObjType("EVA_TEMP");//sourceId:1874249_1
  queryConfItemMatchAnswerDetailComReqDto_1.setConfItemCode("SECOND_LAST_CYCLE_TYPE");//CUSTOM_CONVENTION//sourceId:1673968_1
queryConfItemMatchAnswerDetailComReqDto_1.setIsPlatData("FALSE");//sourceId:1673969_1
if(reqDto!=null){
      queryConfItemMatchAnswerDetailComReqDto_1.setResultAspObjId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:1673967_1
    }
  
    /*D2查第二末级周期类型配置[2486]   */
    Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getResultAspObjId(),"D2准备大屏数据点评价模板配置(公共)-D2查第二末级周期类型配置-开通对象ID不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getResultAspObjType(),"D2准备大屏数据点评价模板配置(公共)-D2查第二末级周期类型配置-开通对象类型编码不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getConfItemCode(),"D2准备大屏数据点评价模板配置(公共)-D2查第二末级周期类型配置-配置项标识不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_1.getIsPlatData(),"D2准备大屏数据点评价模板配置(公共)-D2查第二末级周期类型配置-是否标准答案不能为空",false);
      queryConfItemMatchAnswerDetailComRespDto_2 = confSchemeService.queryConfItemMatchAnswerDetailCom(queryConfItemMatchAnswerDetailComReqDto_1)/*vcase invoke isSameApp*/;
      
      
      
    
//步骤3: D2-3查配置项匹配答案详情(公共)（跨服务） - queryConfItemMatchAnswerDetailCom
     QueryConfItemMatchAnswerDetailComRespDto queryConfItemMatchAnswerDetailComRespDto_4 = null;
    QueryConfItemMatchAnswerDetailComReqDto queryConfItemMatchAnswerDetailComReqDto_2=new QueryConfItemMatchAnswerDetailComReqDto();
  queryConfItemMatchAnswerDetailComReqDto_2.setResultAspObjType("EVA_TEMP");//sourceId:1874248_1
  queryConfItemMatchAnswerDetailComReqDto_2.setConfItemCode("CYCLE_MODE");//CUSTOM_CONVENTION//sourceId:1805051_1
queryConfItemMatchAnswerDetailComReqDto_2.setIsPlatData("FALSE");//sourceId:1805052_1
if(reqDto!=null){
      queryConfItemMatchAnswerDetailComReqDto_2.setResultAspObjId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:1805050_1
    }

    /*D2查周期模式[2486]   */
    Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_2.getResultAspObjId(),"D2准备大屏数据点评价模板配置(公共)-D2查周期模式-开通对象ID不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_2.getResultAspObjType(),"D2准备大屏数据点评价模板配置(公共)-D2查周期模式-开通对象类型编码不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_2.getConfItemCode(),"D2准备大屏数据点评价模板配置(公共)-D2查周期模式-配置项标识不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_2.getIsPlatData(),"D2准备大屏数据点评价模板配置(公共)-D2查周期模式-是否标准答案不能为空",false);
      queryConfItemMatchAnswerDetailComRespDto_4 = confSchemeService.queryConfItemMatchAnswerDetailCom(queryConfItemMatchAnswerDetailComReqDto_2)/*vcase invoke isSameApp*/;




//步骤4: D2-3查配置项匹配答案详情(公共)（跨服务） - queryConfItemMatchAnswerDetailCom
     QueryConfItemMatchAnswerDetailComRespDto queryConfItemMatchAnswerDetailComRespDto_6 = null;
    QueryConfItemMatchAnswerDetailComReqDto queryConfItemMatchAnswerDetailComReqDto_3=new QueryConfItemMatchAnswerDetailComReqDto();
  queryConfItemMatchAnswerDetailComReqDto_3.setConfItemCode("OPEN_MID_CYCLE");//CUSTOM_CONVENTION//sourceId:1805333_1
queryConfItemMatchAnswerDetailComReqDto_3.setIsPlatData("FALSE");//sourceId:1805334_1
if(reqDto!=null){
      queryConfItemMatchAnswerDetailComReqDto_3.setResultAspObjId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:1805332_1
    }

    /*D2查是否开启中期[2486]   */
    Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_3.getResultAspObjId(),"D2准备大屏数据点评价模板配置(公共)-D2查是否开启中期-开通对象ID不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_3.getConfItemCode(),"D2准备大屏数据点评价模板配置(公共)-D2查是否开启中期-配置项标识不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_3.getIsPlatData(),"D2准备大屏数据点评价模板配置(公共)-D2查是否开启中期-是否标准答案不能为空",false);
      queryConfItemMatchAnswerDetailComRespDto_6 = confSchemeService.queryConfItemMatchAnswerDetailCom(queryConfItemMatchAnswerDetailComReqDto_3)/*vcase invoke isSameApp*/;




//步骤5: D2-3查配置项匹配答案详情(公共)（跨服务） - queryConfItemMatchAnswerDetailCom
     QueryConfItemMatchAnswerDetailComRespDto queryConfItemMatchAnswerDetailComRespDto_8 = null;
    QueryConfItemMatchAnswerDetailComReqDto queryConfItemMatchAnswerDetailComReqDto_4=new QueryConfItemMatchAnswerDetailComReqDto();
  queryConfItemMatchAnswerDetailComReqDto_4.setResultAspObjType("EVA_TEMP");//sourceId:1874241_1
queryConfItemMatchAnswerDetailComReqDto_4.setConfItemCode("TARGET_UPDATE_CYCLE_TYPE_CODE");//CUSTOM_CONVENTION//sourceId:1874242_1
queryConfItemMatchAnswerDetailComReqDto_4.setIsPlatData("FALSE");//sourceId:1874243_1
if(reqDto!=null){
      queryConfItemMatchAnswerDetailComReqDto_4.setResultAspObjId(reqDto.getEvaluationTemplateId());//SimpleFieldAssign//sourceId:1874240_1
    }

    /*D2查目标大屏目标更新周期类型配置参数[2486]   */
    Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_4.getResultAspObjId(),"D2准备大屏数据点评价模板配置(公共)-D2查目标大屏目标更新周期类型配置参数-开通对象ID不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_4.getResultAspObjType(),"D2准备大屏数据点评价模板配置(公共)-D2查目标大屏目标更新周期类型配置参数-开通对象类型编码不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_4.getConfItemCode(),"D2准备大屏数据点评价模板配置(公共)-D2查目标大屏目标更新周期类型配置参数-配置项标识不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto_4.getIsPlatData(),"D2准备大屏数据点评价模板配置(公共)-D2查目标大屏目标更新周期类型配置参数-是否标准答案不能为空",false);
      queryConfItemMatchAnswerDetailComRespDto_8 = confSchemeService.queryConfItemMatchAnswerDetailCom(queryConfItemMatchAnswerDetailComReqDto_4)/*vcase invoke isSameApp*/;




//步骤6: M2执行第十接收字段（特殊方法） - implementTenReceivingField
     //ModelCode: receptionService
        ImplementTenReceivingFieldRespDto receptionServiceRes_1 = null;
    if(queryConfItemMatchAnswerDetailComRespDto !=null){
          ImplementTenReceivingFieldReqDto receptionServiceReq_1=new ImplementTenReceivingFieldReqDto();
  if(queryConfItemMatchAnswerDetailComRespDto!=null){
      receptionServiceReq_1.setLastCycleType(queryConfItemMatchAnswerDetailComRespDto.getEndValue());//SimpleFieldAssign//sourceId:1674172_1
    }
if(queryConfItemMatchAnswerDetailComRespDto_2!=null){
      receptionServiceReq_1.setSecondLastCycleType(queryConfItemMatchAnswerDetailComRespDto_2.getEndValue());//SimpleFieldAssign//sourceId:1674173_1
    }
if(queryConfItemMatchAnswerDetailComRespDto_8!=null){
      receptionServiceReq_1.setUpdateCycleTypeCode(queryConfItemMatchAnswerDetailComRespDto_8.getEndValue());//SimpleFieldAssign//sourceId:1874245_1
    }
if(queryConfItemMatchAnswerDetailComRespDto_4!=null){
      receptionServiceReq_1.setCycleMode(queryConfItemMatchAnswerDetailComRespDto_4.getEndValue());//SimpleFieldAssign//sourceId:1805361_1
    }
if(queryConfItemMatchAnswerDetailComRespDto_6!=null){
      receptionServiceReq_1.setOpenMidCycle(queryConfItemMatchAnswerDetailComRespDto_6.getEndValue());//SimpleFieldAssign//sourceId:1805360_1
    }

    /*M2接收末级周期类型配置出参[8782]  用于特殊方法接收上游入参。 */
    Assert.isNull(receptionServiceReq_1.getLastCycleType(),"D2准备大屏数据点评价模板配置(公共)-M2接收末级周期类型配置出参-末级周期类型不能为空",false);
Assert.isNull(receptionServiceReq_1.getCycleMode(),"D2准备大屏数据点评价模板配置(公共)-M2接收末级周期类型配置出参-周期模式不能为空",false);
Assert.isNull(receptionServiceReq_1.getOpenMidCycle(),"D2准备大屏数据点评价模板配置(公共)-M2接收末级周期类型配置出参-是否开启中期不能为空",false);
      receptionServiceRes_1 = nbDashboardTargetContent.implementTenReceivingField(receptionServiceReq_1);
      
      
      receptionServiceRes_2 = receptionServiceRes_1;
           }
    
PreparationDashboardDataPointEvaTempConfComRespDto retData = new PreparationDashboardDataPointEvaTempConfComRespDto();
  if(receptionServiceRes_2!=null){
      retData.setLastCycleType(receptionServiceRes_2.getLastCycleType());//SimpleFieldAssign//sourceId:1674176_1
retData.setSecondLastCycleType(receptionServiceRes_2.getSecondLastCycleType());//SimpleFieldAssign//sourceId:1674177_1
retData.setUpdateCycleTypeCode(receptionServiceRes_2.getUpdateCycleTypeCode());//SimpleFieldAssign//sourceId:1874251_1
retData.setCycleMode(receptionServiceRes_2.getCycleMode());//SimpleFieldAssign//sourceId:1805367_1
retData.setOpenMidCycle(receptionServiceRes_2.getOpenMidCycle());//SimpleFieldAssign//sourceId:1805366_1
    }
  

  
  
return retData;
  }
/**
   * D2执行校验更新周期类型(公共)[9824]
   * gen by moon at 6/16/2024, 7:21:47 PM
   */
  @Trace(operationName = "D2执行校验更新周期类型(公共)")
  @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Transactional(rollbackFor=Exception.class)
  @Override
  public ImplementValidateUpdateCycleTypeComRespDto implementValidateUpdateCycleTypeCom(ImplementValidateUpdateCycleTypeComReqDto reqDto){


      if((reqDto!= null&&  reqDto.getDashboardOpenTypeCode() !=null && reqDto.getDashboardOpenTypeCode().equals("OPEN_TARGET_OTHER_DASHBOARD"))) {
        //if(D2执行校验更新周期类型(公共).大屏开启类型 等于 开目标规划与其他大屏)  70107

QueryConfItemMatchAnswerDetailComRespDto queryConfItemMatchAnswerDetailComRespDto = null;
    QueryConfItemMatchAnswerDetailComReqDto queryConfItemMatchAnswerDetailComReqDto=new QueryConfItemMatchAnswerDetailComReqDto();
  queryConfItemMatchAnswerDetailComReqDto.setConfItemCode("UPDATE_CYCLE_TYPE_CODE");//CUSTOM_CONVENTION//sourceId:1873903_1_70108
queryConfItemMatchAnswerDetailComReqDto.setResultAspObjType("TENANT_SPACE");//sourceId:1873902_1_70108
queryConfItemMatchAnswerDetailComReqDto.setIsPlatData("FALSE");//sourceId:1873905_1_70108
if(reqDto!=null){
      queryConfItemMatchAnswerDetailComReqDto.setEndValue(reqDto.getUpdateCycleTypeCode());//SimpleFieldAssign//sourceId:1873925_1_70108
queryConfItemMatchAnswerDetailComReqDto.setResultAspObjId(reqDto.getSpaceId());//SimpleFieldAssign//sourceId:1873901_1_70108
    }

    /*D2查空间状态大屏更新周期周期类型配置答案[2486]   */
    Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getEndValue(),"D2执行校验更新周期类型(公共)-D2查空间状态大屏更新周期周期类型配置答案-答案值不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getConfItemCode(),"D2执行校验更新周期类型(公共)-D2查空间状态大屏更新周期周期类型配置答案-配置项标识不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getResultAspObjId(),"D2执行校验更新周期类型(公共)-D2查空间状态大屏更新周期周期类型配置答案-开通对象ID不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getResultAspObjType(),"D2执行校验更新周期类型(公共)-D2查空间状态大屏更新周期周期类型配置答案-开通对象类型编码不能为空",false);
Assert.isNull(queryConfItemMatchAnswerDetailComReqDto.getIsPlatData(),"D2执行校验更新周期类型(公共)-D2查空间状态大屏更新周期周期类型配置答案-是否标准答案不能为空",false);
      queryConfItemMatchAnswerDetailComRespDto = confSchemeService.queryConfItemMatchAnswerDetailCom(queryConfItemMatchAnswerDetailComReqDto)/*vcase invoke isSameApp*/;



if((queryConfItemMatchAnswerDetailComRespDto == null )) {
        //if(D2查空间状态大屏更新周期周期类型配置答案.出参 值等于空 )  70109

//异常结束 70110
      throw new BizException("220200457","对不起，工作大屏与规划更新周期不一致，请联系系统管理员~",false);
      }
      }
ImplementValidateUpdateCycleTypeComRespDto retData = new ImplementValidateUpdateCycleTypeComRespDto();





return retData;
  }
  //
}
